package com.lqd.mall.system;

import com.lqd.mall.basis.response.CommonResult;
import com.lqd.mall.basis.response.Result;
import com.lqd.mall.interaction.basis.vo.TableDataInfoVo;
import com.lqd.mall.interaction.system.SysDictDataEntity;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * @author 零起点
 * @create 2022-03-20 21:39
 */
@RequestMapping("/dict/data")
@Api(tags = "字典管理")
public interface SysDictDataControllerApi {

    @GetMapping("/type/{dictType}")
    @ApiOperation("更具字典类型做查询")
    @ApiImplicitParam(name = "dictType", value = "字典类型", paramType = "path", required = true)
    Result<List<SysDictDataEntity>> findSysDictData(@PathVariable("dictType") String dictType);


    @ApiOperation("获取字典值数据")
    @GetMapping("list")
    Result<TableDataInfoVo<SysDictDataEntity>> list(SysDictDataEntity entity);

    @ApiOperation("获取字典值数据")
    @GetMapping("{dictCode}")
    Result<SysDictDataEntity> findSysDictDataById(@PathVariable("dictCode") Long dictCode);


    @ApiOperation("获取字典值数据")
    @PutMapping
    CommonResult updateSysDictDataById(@RequestBody SysDictDataEntity entity);

    @ApiOperation("添加字典数据")
    @PostMapping
    CommonResult saveSysDictDataById(@RequestBody SysDictDataEntity entity);

    @ApiOperation("导出字典值")
    @PostMapping("export")
    void export(HttpServletResponse response, SysDictDataEntity entity);

    @DeleteMapping("{dictCode}")
    @ApiOperation("删除字典值")
    CommonResult deleteSysDictData(@PathVariable("dictCode")Long dictCode);


}
